package com.wdh.kjs.Adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wdh.kjs.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class FM_financerecord_Adapter extends BaseAdapter {
    private List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>();
    private Context context;
    private HashMap<String, String> maps = new HashMap<String, String>();
    private int periods = 0;

    public FM_financerecord_Adapter(Context context, List<HashMap<String, String>> data) {
        this.data = data;
        this.context = context;
    }

    public void resetData(List<HashMap<String, String>> data) {
        this.data.clear();
        this.data.addAll(data);
        this.notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return data.size();
    }

    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return data.get(arg0);
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return arg0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        final ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();

            convertView = View.inflate(context, R.layout.fragment_finance_record, null);

//            viewHolder.financeRecord_type = (TextView) convertView
//                    .findViewById(R.id.financeRecord_type);
            viewHolder.financeRecord_name = (TextView) convertView
                    .findViewById(R.id.financeRecord_name);
            viewHolder.financeRecord_annualRate = (TextView) convertView
                    .findViewById(R.id.financeRecord_annualRate);
            viewHolder.financeRecord_projectTime = (TextView) convertView
                    .findViewById(R.id.financeRecord_projectTime);
            viewHolder.financeRecord_repayType = (TextView) convertView
                    .findViewById(R.id.financeRecord_repayType);
            viewHolder.financeRecord_investMoney = (TextView) convertView
                    .findViewById(R.id.financeRecord_investMoney);
            viewHolder.financeRecord_state = (TextView) convertView
                    .findViewById(R.id.financeRecord_state);
            viewHolder.financeRecord_date = (TextView) convertView
                    .findViewById(R.id.financeRecord_date);
//            viewHolder.financeRecord_time = (TextView) convertView
//                    .findViewById(R.id.financeRecord_time);

//            convertView.findViewById(R.id.bt_mifs_payment_detail).setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    ToastUtils.showShort(context, "跳到回款详情界面");
//                    Intent it = new Intent(context, RepaymentDetailsActivity.class);
//                    context.startActivity(it);
//                }
//            });
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        maps = data.get(position);
//        viewHolder.financeRecord_type.setText(maps.get("financeRecord_type"));
        viewHolder.financeRecord_name.setText(maps.get("financeRecord_name"));
        viewHolder.financeRecord_annualRate.setText(maps.get("financeRecord_annualRate"));
        viewHolder.financeRecord_projectTime.setText(maps.get("financeRecord_projectTime"));
        viewHolder.financeRecord_repayType.setText(maps.get("financeRecord_repayType"));
        viewHolder.financeRecord_investMoney.setText(maps.get("financeRecord_investMoney"));
        viewHolder.financeRecord_state.setText(maps.get("financeRecord_state"));
        viewHolder.financeRecord_date.setText(maps.get("financeRecord_date"));
//        viewHolder.financeRecord_time.setText(maps.get("financeRecord_time"));
        return convertView;
    }
    private class ViewHolder {
//        TextView financeRecord_type;
        TextView financeRecord_name;
        TextView financeRecord_annualRate;
        TextView financeRecord_projectTime;
        TextView financeRecord_repayType;
        TextView financeRecord_date;
        TextView financeRecord_state;
        TextView financeRecord_investMoney;
        TextView financeRecord_time;

    }


}
